<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display" %>

<html>

  <head>
    <title><s:text name="purchasersaction.title"/></title>
    
	<SCRIPT type="text/javascript">
	  // dekorowanie tabeli
	  
	  function decorateTable() {
	      <s:iterator value="list" status="rowstatus">
	        var tableRow = document.getElementById("rstableRow<s:property value='#rowstatus.index'/>");
	        if (tableRow) {
	          tableRow.oldClassName = tableRow.className;
	          tableRow.onmouseover = function() { this.className='hover'; };
	          tableRow.onmouseout = function() { this.className=this.oldClassName; };
	          tableRow.onclick = function() {
	        	  choose("<s:property value='nameJS' escape='false'/>",
	    	        	  "<s:property value='addressJS' escape='false'/>",
	    	        	  "<s:property value='nipJS' escape='false'/>"
	    	      );
	          };
	        }
	      </s:iterator>
	    }
	    
	  // wolane przez chooser.jsp w bodyOnLoad
	  function chooserOnLoad() {
	      decorateTable();
	  }
	  
	  function choose(name, address, nip) {
	    if (window.opener.purchasersChooserChoosed) {
		  window.opener.purchasersChooserChoosed(name, address, nip);
        }
		window.close();
	  }
	
	</script>

  </head>

  <body>

    <%-- pasek tytulowy --%>
    <p class="wwPageTitle">
      <img src="<s:url value='/images/purchaser.gif'/>"/>
      <s:text name="purchasersaction.list"/>
    </p>

    <%-- kryteria wyszukiwania --%>

    <s:actionerror />
    <s:actionmessage/>
    <s:fielderror />

    <s:form namespace="/choosers/purchasers" 
            action="chooserList"
            method="POST"
            validate="true"
            cssClass="wwFilterTable">

      <tr>
        <th colspan="2">
          <s:text name="common.kryteriaWyszukiwania"/>
        </th>
      </tr>

      <s:textfield key="purchasersaction.id"
                   name="filter.id"
                   size="20" />
      
      <s:textfield key="purchasersaction.name"
                   name="filter.name"
                   size="75"/>

      <s:textfield key="purchasersaction.nip"
                   name="filter.nip"
                   size="20"/>

      <tr>
        <td colspan="2" class="wwFilterTableButtonBar">
          <s:submit key="button.show" cssClass="inputButton" theme="simple"/>
        </td>
      </tr>
      
    </s:form>

    <br/>

    <%-- dane --%>

    <s:text id="col1Title" name="purchasersaction.id"/>
    <s:text id="col2Title" name="purchasersaction.name"/>
    <s:text id="col3Title" name="purchasersaction.nip"/>

    <display:table
        class="wwDataTable"
        id="rs"
        defaultsort="1"
        name="list"
        pagesize="10"
        partialList="true"
        size="filter.totalRecords"
        requestURI="list"
        excludedParams="button.show"
        sort="external"
        decorator="org.bigk.invoices.utils.DTagTableDecorator" >

      <display:column property="id"
                      title="${col1Title}"
                      class="nowrap percent1 integer"/>
                      
      <display:column title="${col2Title}">
        <s:property value="#attr.rs.nameHTML" escape="false"/>
      </display:column>

      <display:column property="nip"
                      title="${col3Title}"/>
      
    </display:table>

  </body>

</html>
